package com.bdqn.crm.controller;

import com.bdqn.crm.pojo.SysUser;
import com.bdqn.crm.service.SysUserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class LoginController {
    @Resource
    private SysUserService sysUserService;
    @RequestMapping("/login")
    public String login(String usrName, String usrPassword, Model model, HttpSession session){
        SysUser sysUser = sysUserService.login(usrName,usrPassword);
        if (sysUser != null){
            session.setAttribute("sysUser",sysUser);
            return "main";
        }else {
            model.addAttribute("msg","用户名或密码错误");
            return "forward:/login";
        }

    }
}
